package com.yizhubao.app.activitys;

import android.os.Bundle;
import android.view.View;

import com.yizhubao.app.R;
import com.yizhubao.app.base.BaseActivityToolBar;
import com.yizhubao.app.base.BaseResultBean;
import com.yizhubao.app.customviews.BottomDialog;
import com.yizhubao.app.customviews.inter.OthersCallBack;
import com.yizhubao.app.models.CancellationModel;
import com.yizhubao.app.utils.Constants;
import com.yizhubao.app.utils.Utils;
import com.yizhubao.app.utils.net.BaseObserver;

import butterknife.OnClick;
import h.framework.pacy.utils.PreferencesUtil;
import h.framework.pacy.utils.ToastUtil;

/**
 * 创建人: PACY
 * 创建时间: 6/6/21 10:25 AM
 * 邮箱: pengwwe457621023@qq.com
 * 类描述: 账号注销
 */
public class CancellationActivity extends BaseActivityToolBar {
    CancellationModel model;

    @Override
    protected int setContentLayout() {
        return R.layout.activity_cancellation;
    }

    @Override
    protected void initView() {
        setTitleOnLeftIcon(R.drawable.icon_back,"");
    }

    @Override
    protected void initData() {
        model=new CancellationModel();
    }
    /**
     * 注销请求
     */
    private void logout(){
        showLoading();
        model.logout(new BaseObserver() {
            @Override
            public void onSuccess(BaseResultBean t) {
                if(t.isSuccess()){
                    ToastUtil.showShort("注销成功!");
                    Bundle bundle=new Bundle();
                    bundle.putInt("type",2);
                    startActivity(CancellationActivity.this,ProhibitActivity.class,bundle);
                }
            }

            @Override
            public void onError(String errMessage) {

            }
        },getLifeSubject());
    }

    @OnClick(value = {R.id.submit_tv})
    public void click(View v){
        if(v.getId()==R.id.submit_tv){
            BottomDialog.DialogBuilder(CancellationActivity.this)
                    .title("危险操作")
                    .message("请再仔细想想，是不是确定要注销！？")
                    .completeCallBack(this::logout).completeText("确定注销").cancleText("不注销").othersCallBack(() -> {

                    })
                    .show();
        }
    }
}